package com.google.devrel.example.android.protips.mvp.view;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.google.devrel.example.android.protips.R;
import com.google.devrel.example.android.protips.mvp.ITrackView;
import com.google.devrel.example.android.protips.mvp.TrackPresenter;

public class TrackPhoneFragmentView extends Fragment implements ITrackView {

	TrackPresenter _presenter;

	public TrackPhoneFragmentView() {
		_presenter = new TrackPresenter(this);
	}

	private View rootView;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		rootView = _presenter.getRootView(inflater, container);

		_presenter.fillViewContent(inflater.getContext());

		return rootView;
	}

	@Override
	public void setDeviceId(String str) {
		if (rootView != null) {
			TextView tv = (TextView) rootView.findViewById(R.id.track_deviceId);
			tv.setText(str);
		}
	}

	@Override
	public void setMacAddress(String str) {
		if (rootView != null) {
			TextView tv = (TextView) rootView
					.findViewById(R.id.track_macAddress);
			tv.setText(str);
		}
	}

	@Override
	public void setAndroidId(String str) {
		if (rootView != null) {
			TextView tv = (TextView) rootView
					.findViewById(R.id.track_androidId);
			tv.setText(str);
		}
	}

	@Override
	public void setUniqueInstall(String str) {
		if (rootView != null) {
			TextView tv = (TextView) rootView
					.findViewById(R.id.track_uniqueInst);
			tv.setText(str);
		}
	}

}
